using UnityEngine;
using System.Collections;

public class Tower : MonoBehaviour {

	public float waitTime = 1;
	public Transform bullet;
	public Transform trigger;
    public Color bulletColor;

	void Start()
	{

			foreach (Transform t in transform) {
				if(t.name=="Trigger")
				{
					trigger=t;
				}
			}
		
		StartCoroutine("fire");	
	}
	
	IEnumerator fire () 
	{
		yield return new WaitForSeconds(waitTime);
		Transform t = Instantiate(bullet,trigger.position,trigger.rotation)as Transform;
        t.name = "Ball";
		t.parent = transform.parent;
		t.renderer.material.color = new Color(bulletColor.r,bulletColor.g,bulletColor.b,renderer.material.color.a);
		t.GetComponent<BulletBehaviours>().alpha = renderer;
		StartCoroutine("fire");	
	}
	void OnResume()
	{
		StartCoroutine("fire");
	}
}
